<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
  Class: Chef::Knife::GithubDeploy

    &mdash; Knife Github utilities

</title>

  <link rel="stylesheet" href="../../css/style.css" type="text/css" charset="utf-8" />

  <link rel="stylesheet" href="../../css/common.css" type="text/css" charset="utf-8" />

<script type="text/javascript" charset="utf-8">
  hasFrames = window.top.frames.main ? true : false;
  relpath = '../../';
  framesUrl = "../../frames.html#!" + escape(window.location.href);
</script>


  <script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>

  <script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>


  </head>
  <body>
    <div id="header">
      <div id="menu">

    <a href="../../_index.html">Index (G)</a> &raquo;
    <span class='title'><span class='object_link'><a href="../../Chef.html" title="Chef (class)">Chef</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Knife.html" title="Chef::Knife (class)">Knife</a></span></span>
     &raquo;
    <span class="title">GithubDeploy</span>


  <div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
</div>

      <div id="search">

    <a class="full_list_link" id="class_list_link"
        href="../../class_list.html">
      Class List
    </a>

    <a class="full_list_link" id="method_list_link"
        href="../../method_list.html">
      Method List
    </a>

    <a class="full_list_link" id="file_list_link"
        href="../../file_list.html">
      File List
    </a>

</div>
      <div class="clear"></div>
    </div>

    <iframe id="search_frame"></iframe>

    <div id="content"><h1>Class: Chef::Knife::GithubDeploy



</h1>

<dl class="box">

    <dt class="r1">Inherits:</dt>
    <dd class="r1">
      <span class="inheritName"><span class='object_link'><a href="../Knife.html" title="Chef::Knife (class)">Chef::Knife</a></span></span>

        <ul class="fullTree">
          <li>Object</li>

            <li class="next"><span class='object_link'><a href="../Knife.html" title="Chef::Knife (class)">Chef::Knife</a></span></li>

            <li class="next">Chef::Knife::GithubDeploy</li>

        </ul>
        <a href="#" class="inheritanceTree">show all</a>

      </dd>









    <dt class="r2 last">Defined in:</dt>
    <dd class="r2 last">lib/chef/knife/github_deploy.rb</dd>

</dl>
<div class="clear"></div>

<h2>Overview</h2><div class="docstring">
  <div class="discussion">

<p>Implements the knife github deploy function</p>
<table class="rdoc-list"><tr><td class="rdoc-term"><p>@author</p></td>
<td>
<p>Ian Southam (&lt;isoutham@schubergphilis.com&gt;)</p>
</td></tr><tr><td class="rdoc-term"><p>Copyright</p></td>
<td>
<p>Copyright (c) 2013 Ian Southam.</p>
</td></tr></table>

<p>This code is specific to our company workflow</p>

<h2>Overview</h2>

<p>All modes presume you have used github download to download a cookbook or
are creating a new cookbook</p>

<h3>Examples</h3>

<p>Deploy a development version of cookbook to your chef server</p>

<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_knife'>knife</span> <span class='id identifier rubyid_github'>github</span> <span class='id identifier rubyid_deploy'>deploy</span> <span class='id identifier rubyid_cookbook_name'>cookbook_name</span></code></pre>

<p>Deploy a release version of cookbook to your chef server</p>

<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_knife'>knife</span> <span class='id identifier rubyid_github'>github</span> <span class='id identifier rubyid_deploy'>deploy</span> <span class='id identifier rubyid_cookbook_name'>cookbook_name</span> <span class='op'>-</span><span class='id identifier rubyid_f'>f</span></code></pre>

<h3>Options</h3>

<p>-f Operate in final release mode -p Update the patch component of the
version -m Update the minor component of the version -M Update the minor
component of the version</p>

<h2>Operation Modes</h2>

<p>Development (default)</p>

<p>This will take a cookbook name Do some basic version checks (if the current
cookbook is frozen) and upload it</p>

<p>If the cookbook is frozen it will force you to choose a new version and
update the metadata accordingly</p>

<p>Release (-f)</p>

<p>You will be forced to select a new version. You can choose via the options
whether to increment the Major/minor or patch revision numbers The version
will be tagged Uploaded to the Chef server and frozen</p>

<h2>Version numbers</h2>

<p>You can choose a specific version number by specifying it on the command
line.</p>

<p>If you do not specify a version, the version will be the version in your
cookbook's metadata</p>

<p>A warning is issued if the version is lower than the version in github</p>


  </div>
</div>
<div class="tags">


</div>







    <h2>
      Instance Method Summary
      <small>(<a href="#" class="summary_toggle">collapse</a>)</small>
    </h2>

    <ul class="summary">

        <li class="public ">
  <span class="summary_signature">

      <a href="#checkout_tag-instance_method" title="#checkout_tag (instance method)">- (Object) <strong>checkout_tag</strong>(version) </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>If a tag is available in github check it out Potentially quite dangerous as
it could cause code to get rolled back.</p>
</div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#choose_version-instance_method" title="#choose_version (instance method)">- (String) <strong>choose_version</strong>(version) </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>Increment the current version according to the config options <a
href="http://major">config</a> <a href="http://minor">config</a> <a
href="http://patch">config</a> Method will exit if the user chooses not to
increment the version.</p>
</div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#cookbook_upload-instance_method" title="#cookbook_upload (instance method)">- (Object) <strong>cookbook_upload</strong> </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>Upload the cookbook to chef server If mode is final, freeze the cookbook.</p>
</div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#do_commit-instance_method" title="#do_commit (instance method)">- (Object) <strong>do_commit</strong>(version, push) </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>Commit changes in git.</p>
</div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#get_cookbook_chef_versions-instance_method" title="#get_cookbook_chef_versions (instance method)">- (Object) <strong>get_cookbook_chef_versions</strong> </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>Get a sorted array of version for the cookbook.</p>
</div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#get_cookbook_path-instance_method" title="#get_cookbook_path (instance method)">- (String) <strong>get_cookbook_path</strong>(cookbook) </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>Determine if the current cookbook path is valid and that there is a
cookbook of the correct name in there.</p>
</div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#get_cookbook_version-instance_method" title="#get_cookbook_version (instance method)">- (Object) <strong>get_cookbook_version</strong> </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>Get the version number in the git version of the cookbook.</p>
</div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#run-instance_method" title="#run (instance method)">- (Object) <strong>run</strong> </a>



  </span>









    <span class="summary_desc"><div class='inline'></div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#set_cookbook_version-instance_method" title="#set_cookbook_version (instance method)">- (Object) <strong>set_cookbook_version</strong>(version) </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>Set the version in metadata.rb.</p>
</div></span>

</li>


        <li class="public ">
  <span class="summary_signature">

      <a href="#up_version-instance_method" title="#up_version (instance method)">- (String) <strong>up_version</strong>(version) </a>



  </span>









    <span class="summary_desc"><div class='inline'>
<p>Ask user to increment current/desired version number Method will exit if
the user chooses not to increment the version.</p>
</div></span>

</li>


    </ul>










  <div id="instance_method_details" class="method_details_list">
    <h2>Instance Method Details</h2>


      <div class="method_details first">
  <h3 class="signature first" id="checkout_tag-instance_method">

    - (<tt>Object</tt>) <strong>checkout_tag</strong>(version)





</h3><div class="docstring">
  <div class="discussion">

<p>If a tag is available in github check it out Potentially quite dangerous as
it could cause code to get rolled back</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">

    <li>

        <span class='name'>version</span>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>Version</p>
</div>

    </li>

</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


270
271
272
273
274
275
276
277
278
279</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 270</span>

<span class='kw'>def</span> <span class='id identifier rubyid_checkout_tag'>checkout_tag</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Checking out tag </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_version'>version</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span>
    <span class='id identifier rubyid_cpath'>cpath</span> <span class='op'>=</span> <span class='id identifier rubyid_get_cookbook_path'>get_cookbook_path</span><span class='lparen'>(</span><span class='ivar'>@cookbook_name</span><span class='rparen'>)</span>
    <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_chdir'>chdir</span><span class='lparen'>(</span><span class='id identifier rubyid_cpath'>cpath</span><span class='rparen'>)</span><span class='semicolon'>;</span>
		  <span class='backtick'>`</span><span class='tstring_content'>git checkout -b </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_version'>version</span><span class='rbrace'>}</span><span class='tstring_end'>`</span></span>
		  <span class='kw'>if</span> <span class='op'>!</span><span class='gvar'>$?</span><span class='period'>.</span><span class='id identifier rubyid_exitstatus'>exitstatus</span> <span class='op'>==</span> <span class='int'>0</span>
 <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Failed to checkout branch </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_version'>version</span><span class='rbrace'>}</span><span class='tstring_content'> of </span><span class='embexpr_beg'>#{</span><span class='ivar'>@cookbook_name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
 <span class='id identifier rubyid_exit'>exit</span> <span class='int'>1</span>
    <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="choose_version-instance_method">

    - (<tt>String</tt>) <strong>choose_version</strong>(version)





</h3><div class="docstring">
  <div class="discussion">

<p>Increment the current version according to the config options <a
href="http://major">config</a> <a href="http://minor">config</a> <a
href="http://patch">config</a> Method will exit if the user chooses not to
increment the version</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">

    <li>

        <span class='name'>version</span>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>Version</p>
</div>

    </li>

</ul>

<p class="tag_title">Returns:</p>
<ul class="return">

    <li>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>New version number</p>
</div>

    </li>

</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 234</span>

<span class='kw'>def</span> <span class='id identifier rubyid_choose_version'>choose_version</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='rparen'>)</span>
    <span class='kw'>if</span> <span class='id identifier rubyid_version'>version</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(\d+)\.(\d+)\.(\d+)</span><span class='regexp_end'>/</span></span>
       <span class='id identifier rubyid_major'>major</span> <span class='op'>=</span> <span class='backref'>$1</span>
       <span class='id identifier rubyid_minor'>minor</span> <span class='op'>=</span> <span class='backref'>$2</span>
       <span class='id identifier rubyid_patch'>patch</span> <span class='op'>=</span> <span class='backref'>$3</span>
       <span class='id identifier rubyid_major'>major</span> <span class='op'>=</span> <span class='id identifier rubyid_major'>major</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>+</span> <span class='int'>1</span> <span class='kw'>if</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:major</span><span class='rbracket'>]</span>
       <span class='id identifier rubyid_minor'>minor</span> <span class='op'>=</span> <span class='id identifier rubyid_minor'>minor</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>+</span> <span class='int'>1</span> <span class='kw'>if</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:minor</span><span class='rbracket'>]</span>
       <span class='id identifier rubyid_patch'>patch</span> <span class='op'>=</span> <span class='id identifier rubyid_patch'>patch</span><span class='period'>.</span><span class='id identifier rubyid_to_i'>to_i</span> <span class='op'>+</span> <span class='int'>1</span> <span class='kw'>if</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:patch</span><span class='rbracket'>]</span>
       <span class='id identifier rubyid_version'>version</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_major'>major</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_minor'>minor</span><span class='rbrace'>}</span><span class='tstring_content'>.</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_patch'>patch</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span>
       <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id identifier rubyid_debug'>debug</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>New version is </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_version'>version</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='kw'>else</span>
       <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Version is in a format I cannot auto auto-update</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
       <span class='id identifier rubyid_exit'>exit</span> <span class='int'>1</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_version'>version</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="cookbook_upload-instance_method">

    - (<tt>Object</tt>) <strong>cookbook_upload</strong>





</h3><div class="docstring">
  <div class="discussion">

<p>Upload the cookbook to chef server If mode is final, freeze the cookbook</p>


  </div>
</div>
<div class="tags">


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


253
254
255
256
257
258
259
260
261
262
263
264</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 253</span>

<span class='kw'>def</span> <span class='id identifier rubyid_cookbook_upload'>cookbook_upload</span><span class='lparen'>(</span><span class='rparen'>)</span>
    <span class='comment'># Git meuk should not be uploaded use chefignore file instead
</span>    <span class='comment'># FileUtils.remove_entry(&quot;#{@github_tmp}/git/#{@cookbook_name}/.git&quot;)
</span>		  <span class='id identifier rubyid_args'>args</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>cookbook</span><span class='tstring_end'>'</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>upload</span><span class='tstring_end'>'</span></span><span class='comma'>,</span>  <span class='ivar'>@cookbook_name</span> <span class='rbracket'>]</span>
    <span class='kw'>if</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:final</span><span class='rbracket'>]</span>
        <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>--freeze</span><span class='tstring_end'>&quot;</span></span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_upload'>upload</span> <span class='op'>=</span> <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Knife</span><span class='op'>::</span><span class='const'>CookbookUpload</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
    <span class='comment'>#upload.config[:cookbook_path] = &quot;#{@github_tmp}/git&quot;
</span>    <span class='comment'># plugin will throw its own errors
</span>    <span class='id identifier rubyid_upload'>upload</span><span class='period'>.</span><span class='id identifier rubyid_run'>run</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="do_commit-instance_method">

    - (<tt>Object</tt>) <strong>do_commit</strong>(version, push)





</h3><div class="docstring">
  <div class="discussion">

<p>Commit changes in git</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">

    <li>

        <span class='name'>version</span>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>cookbook version</p>
</div>

    </li>

    <li>

        <span class='name'>push</span>


        <span class='type'>(<tt>Bool</tt>)</span>



        &mdash;
        <div class='inline'>
<p>true is the cookbook should also be pushed</p>
</div>

    </li>

</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 318</span>

<span class='kw'>def</span> <span class='id identifier rubyid_do_commit'>do_commit</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='comma'>,</span> <span class='id identifier rubyid_push'>push</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_cpath'>cpath</span> <span class='op'>=</span> <span class='id identifier rubyid_get_cookbook_path'>get_cookbook_path</span><span class='lparen'>(</span><span class='ivar'>@cookbook_name</span><span class='rparen'>)</span>
    <span class='const'>Dir</span><span class='period'>.</span><span class='id identifier rubyid_chdir'>chdir</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cpath'>cpath</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_cpath'>cpath</span>
    <span class='id identifier rubyid_output'>output</span> <span class='op'>=</span> <span class='backtick'>`</span><span class='tstring_content'>git commit -a -m &quot;Deploy </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_version'>version</span><span class='rbrace'>}</span><span class='tstring_content'>&quot; 2&gt;&amp;1</span><span class='tstring_end'>`</span></span>
    <span class='kw'>if</span> <span class='gvar'>$?</span><span class='period'>.</span><span class='id identifier rubyid_exitstatus'>exitstatus</span> <span class='op'>!=</span> <span class='int'>0</span>
       <span class='kw'>if</span> <span class='id identifier rubyid_output'>output</span> <span class='op'>!~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>nothing to commit</span><span class='regexp_end'>/</span></span>
          <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Could not commit </span><span class='embexpr_beg'>#{</span><span class='ivar'>@cookbook_name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
          <span class='id identifier rubyid_puts'>puts</span> <span class='id identifier rubyid_output'>output</span>
          <span class='id identifier rubyid_exit'>exit</span> <span class='int'>1</span>
       <span class='kw'>end</span>
    <span class='kw'>end</span>
    <span class='kw'>if</span> <span class='id identifier rubyid_push'>push</span>
        <span class='id identifier rubyid_output'>output</span> <span class='op'>=</span> <span class='backtick'>`</span><span class='tstring_content'>git push --tags 2&gt;&amp;1</span><span class='tstring_end'>`</span></span>
        <span class='kw'>if</span> <span class='gvar'>$?</span><span class='period'>.</span><span class='id identifier rubyid_exitstatus'>exitstatus</span> <span class='op'>!=</span> <span class='int'>0</span>
           <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Could not push tag for: </span><span class='embexpr_beg'>#{</span><span class='ivar'>@cookbook_name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
           <span class='id identifier rubyid_exit'>exit</span> <span class='int'>1</span>
        <span class='kw'>end</span>
        <span class='id identifier rubyid_output'>output</span> <span class='op'>=</span> <span class='backtick'>`</span><span class='tstring_content'>git push 2&gt;&amp;1</span><span class='tstring_end'>`</span></span>
    <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="get_cookbook_chef_versions-instance_method">

    - (<tt>Object</tt>) <strong>get_cookbook_chef_versions</strong>





</h3><div class="docstring">
  <div class="discussion">

<p>Get a sorted array of version for the cookbook</p>


  </div>
</div>
<div class="tags">


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


282
283
284
285
286
287</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 282</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_cookbook_chef_versions'>get_cookbook_chef_versions</span> <span class='lparen'>(</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_cookbooks'>cookbooks</span> <span class='op'>=</span> <span class='id identifier rubyid_rest'>rest</span><span class='period'>.</span><span class='id identifier rubyid_get_rest'>get_rest</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/cookbooks/</span><span class='embexpr_beg'>#{</span><span class='ivar'>@cookbook_name</span><span class='rbrace'>}</span><span class='tstring_content'>?num_version=all</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='id identifier rubyid_cookbooks'>cookbooks</span><span class='lbracket'>[</span><span class='ivar'>@cookbook_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>versions</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span>
        <span class='ivar'>@versions</span><span class='period'>.</span><span class='id identifier rubyid_push'>push</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>version</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span>
    <span class='kw'>end</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="get_cookbook_path-instance_method">

    - (<tt>String</tt>) <strong>get_cookbook_path</strong>(cookbook)





</h3><div class="docstring">
  <div class="discussion">

<p>Determine if the current cookbook path is valid and that there is a
cookbook of the correct name in there</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">

    <li>

        <span class='name'>cookbook</span>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>cookbook name</p>
</div>

    </li>

</ul>

<p class="tag_title">Returns:</p>
<ul class="return">

    <li>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>Path to cookbook</p>
</div>

    </li>

</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


311
312
313</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 311</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_cookbook_path'>get_cookbook_path</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook'>cookbook</span><span class='rparen'>)</span>
    <span class='kw'>return</span> <span class='id identifier rubyid_cookbook_path_valid?'>cookbook_path_valid?</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook'>cookbook</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="get_cookbook_version-instance_method">

    - (<tt>Object</tt>) <strong>get_cookbook_version</strong>





</h3><div class="docstring">
  <div class="discussion">

<p>Get the version number in the git version of the cookbook</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">

    <li>

        <span class='name'>version</span>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>Version</p>
</div>

    </li>

</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


291
292
293
294
295
296
297
298
299
300
301
302
303
304
305</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 291</span>

<span class='kw'>def</span> <span class='id identifier rubyid_get_cookbook_version'>get_cookbook_version</span><span class='lparen'>(</span><span class='rparen'>)</span>
    <span class='id identifier rubyid_version'>version</span> <span class='op'>=</span> <span class='kw'>nil</span>
    <span class='id identifier rubyid_cpath'>cpath</span> <span class='op'>=</span> <span class='id identifier rubyid_get_cookbook_path'>get_cookbook_path</span><span class='lparen'>(</span><span class='ivar'>@cookbook_name</span><span class='rparen'>)</span>
    <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_foreach'>foreach</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cpath'>cpath</span><span class='rbrace'>}</span><span class='tstring_content'>/metadata.rb</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
        <span class='kw'>if</span> <span class='id identifier rubyid_line'>line</span> <span class='op'>=~</span> <span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>version.*&quot;(.*)&quot;</span><span class='regexp_end'>/i</span></span>
           <span class='id identifier rubyid_version'>version</span> <span class='op'>=</span> <span class='backref'>$1</span>
           <span class='kw'>break</span>
        <span class='kw'>end</span>
    <span class='kw'>end</span>
    <span class='kw'>if</span> <span class='id identifier rubyid_version'>version</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
       <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cannot get the version for cookbook </span><span class='embexpr_beg'>#{</span><span class='ivar'>@cookbook_name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
       <span class='id identifier rubyid_exit'>exit</span> <span class='int'>1</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_version'>version</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="run-instance_method">

    - (<tt>Object</tt>) <strong>run</strong>





</h3><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 94</span>

<span class='kw'>def</span> <span class='id identifier rubyid_run'>run</span>
  <span class='comment'># Main run entry point for the class
</span>
  <span class='id identifier rubyid_validate_base_options'>validate_base_options</span>

  <span class='id identifier rubyid_display_debug_info'>display_debug_info</span>

  <span class='comment'># Gather all repo information from github.
</span>  <span class='id identifier rubyid_get_all_repos'>get_all_repos</span> <span class='op'>=</span> <span class='id identifier rubyid_get_all_repos'>get_all_repos</span><span class='lparen'>(</span><span class='ivar'>@github_organizations</span><span class='period'>.</span><span class='id identifier rubyid_reverse'>reverse</span><span class='rparen'>)</span>

  <span class='comment'># Get all chef cookbooks and versions (hopefully chef does the error handeling).
</span>  <span class='id identifier rubyid_cookbooks'>cookbooks</span> <span class='op'>=</span> <span class='id identifier rubyid_rest'>rest</span><span class='period'>.</span><span class='id identifier rubyid_get_rest'>get_rest</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>/cookbooks?num_version=1</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>

  <span class='ivar'>@versions</span> <span class='op'>=</span> <span class='lbracket'>[</span><span class='rbracket'>]</span>
  <span class='id identifier rubyid_cookbook_version'>cookbook_version</span> <span class='op'>=</span> <span class='kw'>nil</span>
  <span class='ivar'>@cookbook_name</span> <span class='op'>=</span> <span class='id identifier rubyid_name_args'>name_args</span><span class='period'>.</span><span class='id identifier rubyid_first'>first</span> <span class='kw'>unless</span> <span class='id identifier rubyid_name_args'>name_args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
  <span class='id identifier rubyid_cookbook_version'>cookbook_version</span> <span class='op'>=</span> <span class='id identifier rubyid_name_args'>name_args</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span> <span class='kw'>unless</span> <span class='id identifier rubyid_name_args'>name_args</span><span class='lbracket'>[</span><span class='int'>1</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>

  <span class='kw'>if</span> <span class='ivar'>@cookbook_name</span>
    <span class='id identifier rubyid_repo'>repo</span> <span class='op'>=</span> <span class='id identifier rubyid_get_all_repos'>get_all_repos</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='comma'>,</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_v'>v</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>name</span><span class='tstring_end'>&quot;</span></span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='ivar'>@cookbook_name</span> <span class='rbrace'>}</span>
  <span class='kw'>else</span>
    <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cookbook not in git.  You must add it to git to use deploy</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='id identifier rubyid_exit'>exit</span> <span class='int'>1</span>
  <span class='kw'>end</span>

  <span class='kw'>if</span> <span class='id identifier rubyid_repo'>repo</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
    <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cookbook not in git.  You must add it to git to use deploy</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='id identifier rubyid_exit'>exit</span> <span class='int'>1</span>
  <span class='kw'>end</span>

  <span class='comment'># is the cookbook in the cookbook_path?
</span>  <span class='kw'>if</span> <span class='id identifier rubyid_cookbook_path_valid?'>cookbook_path_valid?</span><span class='lparen'>(</span><span class='ivar'>@cookbook_name</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
    <span class='const'>Chef</span><span class='op'>::</span><span class='const'>Log</span><span class='period'>.</span><span class='id identifier rubyid_error'>error</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cookbook is not in cookbook path</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>HINT:  knife github clone </span><span class='embexpr_beg'>#{</span><span class='ivar'>@cookbook_name</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
    <span class='id identifier rubyid_exit'>exit</span> <span class='int'>1</span>
  <span class='kw'>end</span>

  <span class='comment'># ----------------------------- #
</span>  <span class='comment'># The version can come
</span>  <span class='comment'># 1.  From the command line
</span>  <span class='comment'># 2.  From the cookbook
</span>  <span class='comment'># ----------------------------- #
</span>  <span class='kw'>if</span> <span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
     <span class='id identifier rubyid_cookbook_version'>cookbook_version</span> <span class='op'>=</span> <span class='id identifier rubyid_get_cookbook_version'>get_cookbook_version</span><span class='lparen'>(</span><span class='rparen'>)</span>
  <span class='kw'>end</span>
  <span class='comment'># Next check to see if the version in git is way ahead
</span>  <span class='kw'>if</span> <span class='op'>!</span> <span class='id identifier rubyid_get_all_repos'>get_all_repos</span><span class='lbracket'>[</span><span class='ivar'>@cookbook_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>latest_tag</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
      <span class='id identifier rubyid_cb1'>cb1</span> <span class='op'>=</span> <span class='const'>Mixlib</span><span class='op'>::</span><span class='const'>Versioning</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rparen'>)</span>
      <span class='id identifier rubyid_cb2'>cb2</span> <span class='op'>=</span> <span class='const'>Mixlib</span><span class='op'>::</span><span class='const'>Versioning</span><span class='period'>.</span><span class='id identifier rubyid_parse'>parse</span><span class='lparen'>(</span><span class='id identifier rubyid_get_all_repos'>get_all_repos</span><span class='lbracket'>[</span><span class='ivar'>@cookbook_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>latest_tag</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='rparen'>)</span>
      <span class='kw'>if</span><span class='lparen'>(</span><span class='id identifier rubyid_cb2'>cb2</span> <span class='op'>&gt;</span> <span class='id identifier rubyid_cb1'>cb1</span><span class='rparen'>)</span>
          <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_confirm'>confirm</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Version in github </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cb2'>cb2</span><span class='rbrace'>}</span><span class='tstring_content'> is greater than the version you want to deploy </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cb1'>cb1</span><span class='rbrace'>}</span><span class='tstring_content'> - Continue</span><span class='tstring_end'>&quot;</span></span>
      <span class='kw'>end</span>
  <span class='kw'>end</span>

  <span class='id identifier rubyid_inChef'>inChef</span> <span class='op'>=</span> <span class='kw'>true</span>
  <span class='id identifier rubyid_isFrozen'>isFrozen</span> <span class='op'>=</span> <span class='kw'>false</span>
  <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:major</span><span class='rbracket'>]</span> <span class='op'>||</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:minor</span><span class='rbracket'>]</span><span class='rparen'>)</span>
      <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:patch</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>false</span>
  <span class='kw'>end</span>
  <span class='kw'>if</span> <span class='lparen'>(</span><span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:major</span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:minor</span><span class='rbracket'>]</span><span class='rparen'>)</span>
      <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:minor</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='kw'>false</span>
  <span class='kw'>end</span>

  <span class='kw'>begin</span>
      <span class='id identifier rubyid_isFrozen'>isFrozen</span> <span class='op'>=</span> <span class='id identifier rubyid_rest'>rest</span><span class='period'>.</span><span class='id identifier rubyid_get_rest'>get_rest</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>cookbooks/</span><span class='embexpr_beg'>#{</span><span class='ivar'>@cookbook_name</span><span class='rbrace'>}</span><span class='tstring_content'>/</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_frozen_version?'>frozen_version?</span>
  <span class='kw'>rescue</span>
      <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_warn'>warn</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='ivar'>@cookbook_name</span><span class='rbrace'>}</span><span class='tstring_content'> is not yet in chef</span><span class='tstring_end'>&quot;</span></span>
      <span class='id identifier rubyid_inChef'>inChef</span> <span class='op'>=</span> <span class='kw'>false</span>
  <span class='kw'>end</span>


  <span class='kw'>if</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:final</span><span class='rbracket'>]</span>
      <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Using Final mode</span><span class='tstring_end'>&quot;</span></span>

  <span class='kw'>else</span>
      <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Using Development mode</span><span class='tstring_end'>&quot;</span></span>
  <span class='kw'>end</span>
  <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cookbook is frozen</span><span class='tstring_end'>&quot;</span></span> <span class='kw'>if</span> <span class='id identifier rubyid_isFrozen'>isFrozen</span>

  <span class='comment'># Might be first upload so need to catch that cookbook does not exist!
</span>  <span class='id identifier rubyid_get_cookbook_chef_versions'>get_cookbook_chef_versions</span><span class='lparen'>(</span><span class='rparen'>)</span>  <span class='kw'>unless</span> <span class='op'>!</span> <span class='id identifier rubyid_inChef'>inChef</span>

  <span class='kw'>if</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:final</span><span class='rbracket'>]</span>
      <span class='id identifier rubyid_cookbook_version'>cookbook_version</span> <span class='op'>=</span> <span class='id identifier rubyid_up_version'>up_version</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rparen'>)</span>

      <span class='kw'>if</span> <span class='id identifier rubyid_repo'>repo</span><span class='lbracket'>[</span><span class='ivar'>@cookbook_name</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>tags</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_select'>select</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_k'>k</span><span class='op'>|</span> <span class='id identifier rubyid_k'>k</span><span class='lbracket'>[</span><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>name</span><span class='tstring_end'>'</span></span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='id identifier rubyid_cookbook_version'>cookbook_version</span> <span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
          <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Cookbook </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rbrace'>}</span><span class='tstring_content'> has no tag in Git</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
          <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_confirm'>confirm</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Shall I add a tag for you?</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
          <span class='id identifier rubyid_set_cookbook_version'>set_cookbook_version</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rparen'>)</span>
          <span class='id identifier rubyid_add_tag'>add_tag</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rparen'>)</span>
      <span class='kw'>else</span>
          <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_confirm'>confirm</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Tag </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rbrace'>}</span><span class='tstring_content'> exists - did you make this for this release?</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
          <span class='id identifier rubyid_checkout_tag'>checkout_tag</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rparen'>)</span>
          <span class='id identifier rubyid_set_cookbook_version'>set_cookbook_version</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rparen'>)</span>
      <span class='kw'>end</span>

      <span class='id identifier rubyid_do_commit'>do_commit</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='comma'>,</span> <span class='kw'>true</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># In Dev mode the version of the cookbook does not need to change
</span>  <span class='comment'># If however the cookbook is frozen, then the version has to change
</span>  <span class='kw'>if</span> <span class='op'>!</span> <span class='id identifier rubyid_config'>config</span><span class='lbracket'>[</span><span class='symbol'>:final</span><span class='rbracket'>]</span> <span class='op'>&amp;&amp;</span> <span class='id identifier rubyid_isFrozen'>isFrozen</span>
      <span class='id identifier rubyid_cookbook_version'>cookbook_version</span> <span class='op'>=</span> <span class='id identifier rubyid_up_version'>up_version</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rparen'>)</span>
      <span class='id identifier rubyid_set_cookbook_version'>set_cookbook_version</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='rparen'>)</span>
      <span class='id identifier rubyid_do_commit'>do_commit</span><span class='lparen'>(</span><span class='id identifier rubyid_cookbook_version'>cookbook_version</span><span class='comma'>,</span> <span class='kw'>false</span><span class='rparen'>)</span>
  <span class='kw'>end</span>

  <span class='comment'># If we have gotten this far we can just upload the cookbook
</span>  <span class='id identifier rubyid_cookbook_upload'>cookbook_upload</span><span class='lparen'>(</span><span class='rparen'>)</span>

<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="set_cookbook_version-instance_method">

    - (<tt>Object</tt>) <strong>set_cookbook_version</strong>(version)





</h3><div class="docstring">
  <div class="discussion">

<p>Set the version in metadata.rb</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">

    <li>

        <span class='name'>version</span>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>cookbook version</p>
</div>

    </li>

</ul>


</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


343
344
345
346
347
348
349
350
351
352
353</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 343</span>

<span class='kw'>def</span> <span class='id identifier rubyid_set_cookbook_version'>set_cookbook_version</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='rparen'>)</span>
    <span class='kw'>return</span>  <span class='kw'>unless</span> <span class='id identifier rubyid_get_cookbook_version'>get_cookbook_version</span><span class='lparen'>(</span><span class='rparen'>)</span> <span class='op'>!=</span> <span class='id identifier rubyid_version'>version</span>
    <span class='id identifier rubyid_contents'>contents</span> <span class='op'>=</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_end'>'</span></span>
    <span class='id identifier rubyid_cpath'>cpath</span> <span class='op'>=</span> <span class='id identifier rubyid_get_cookbook_path'>get_cookbook_path</span><span class='lparen'>(</span><span class='ivar'>@cookbook_name</span><span class='rparen'>)</span>
    <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_foreach'>foreach</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cpath'>cpath</span><span class='rbrace'>}</span><span class='tstring_content'>/metadata.rb</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_line'>line</span><span class='op'>|</span>
        <span class='id identifier rubyid_line'>line</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>(version[\t\s]+)(.*)</span><span class='regexp_end'>/i</span></span><span class='comma'>,</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>\\1 \&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_version'>version</span><span class='rbrace'>}</span><span class='tstring_content'>\&quot;\n</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
        <span class='id identifier rubyid_contents'>contents</span> <span class='op'>=</span> <span class='id identifier rubyid_contents'>contents</span> <span class='op'>&lt;&lt;</span> <span class='id identifier rubyid_line'>line</span>
    <span class='kw'>end</span>
    <span class='const'>File</span><span class='period'>.</span><span class='id identifier rubyid_open'>open</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_cpath'>cpath</span><span class='rbrace'>}</span><span class='tstring_content'>/metadata.rb</span><span class='tstring_end'>&quot;</span></span><span class='comma'>,</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>w</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span> <span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_f'>f</span><span class='op'>|</span> <span class='id identifier rubyid_f'>f</span><span class='period'>.</span><span class='id identifier rubyid_write'>write</span><span class='lparen'>(</span><span class='id identifier rubyid_contents'>contents</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
    <span class='kw'>return</span> <span class='kw'>true</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

      <div class="method_details ">
  <h3 class="signature " id="up_version-instance_method">

    - (<tt>String</tt>) <strong>up_version</strong>(version)





</h3><div class="docstring">
  <div class="discussion">

<p>Ask user to increment current/desired version number Method will exit if
the user chooses not to increment the version</p>


  </div>
</div>
<div class="tags">
  <p class="tag_title">Parameters:</p>
<ul class="param">

    <li>

        <span class='name'>version</span>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>Version</p>
</div>

    </li>

</ul>

<p class="tag_title">Returns:</p>
<ul class="return">

    <li>


        <span class='type'>(<tt>String</tt>)</span>



        &mdash;
        <div class='inline'>
<p>New version number</p>
</div>

    </li>

</ul>

</div><table class="source_code">
  <tr>
    <td>
      <pre class="lines">


212
213
214
215
216
217
218
219
220
221
222
223
224
225</pre>
    </td>
    <td>
      <pre class="code"><span class="info file"># File 'lib/chef/knife/github_deploy.rb', line 212</span>

<span class='kw'>def</span> <span class='id identifier rubyid_up_version'>up_version</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='rparen'>)</span>
    <span class='kw'>while</span> <span class='kw'>true</span> <span class='kw'>do</span>
          <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Trying to deploy version </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_version'>version</span><span class='rbrace'>}</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
          <span class='kw'>if</span> <span class='ivar'>@versions</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='rparen'>)</span>
             <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_info'>info</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Version </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_version'>version</span><span class='rbrace'>}</span><span class='tstring_content'> is already in chef</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
             <span class='id identifier rubyid_vt'>vt</span> <span class='op'>=</span> <span class='id identifier rubyid_choose_version'>choose_version</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='rparen'>)</span>
             <span class='id identifier rubyid_ui'>ui</span><span class='period'>.</span><span class='id identifier rubyid_confirm'>confirm</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Shall I bump the version to </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_vt'>vt</span><span class='rbrace'>}</span><span class='tstring_content'> (No to Cancel)</span><span class='tstring_end'>&quot;</span></span><span class='rparen'>)</span>
             <span class='id identifier rubyid_version'>version</span> <span class='op'>=</span> <span class='id identifier rubyid_choose_version'>choose_version</span><span class='lparen'>(</span><span class='id identifier rubyid_version'>version</span><span class='rparen'>)</span>
          <span class='kw'>else</span>
             <span class='kw'>break</span>
          <span class='kw'>end</span>
    <span class='kw'>end</span>
    <span class='id identifier rubyid_version'>version</span>
<span class='kw'>end</span></pre>
    </td>
  </tr>
</table>
</div>

  </div>

</div>

    <div id="footer">
  Generated on Wed Oct 30 21:59:25 2013 by
  <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
  0.8.7.2 (ruby-1.9.3).
</div>

  </body>
</html>